<!--
 * @description  :情报处置反馈-市管调查表单
 * @descriptionDetail:情报处置反馈-市管调查表单
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<!--
  市管调查 表单
-->
<template>
  <view class="single-page">
    <theme-navbar
      :isBack="false"
      :is-white="false"
      title="市场调查"
      style="z-index: 99999;"
    >
      <view class="nav-right-icon" @click="handlerConfirm">
        确定
      </view>
    </theme-navbar>
    <view class="content">
      <u-form
        :model="resultInfo"
        :error-type="['border-bottom', 'message',]"
        label-width="auto"
        label-position="top"
        ref="resultForm"
      >
        <form-section title="处置方式"></form-section>
        <u-form-item label="方式" prop="result">
          <u-radio-group v-model="resultInfo.result">
            <u-radio
              v-for="(item, index) in radioList"
              :key="index"
              :name="item.value"
              :disabled="item.disabled"
            >
              {{ item.name }}
            </u-radio>
          </u-radio-group>
        </u-form-item>
        <u-form-item label="备注">
          <u-input type="textarea" v-model="resultInfo.remark" placeHolder="请输入..."></u-input>
        </u-form-item>
      </u-form>
    </view>
  </view>
</template>

<script>
import formSection from "@/components/form-section.vue";
import inteligenceService from '@/service/intelligence/intelligence.service.js';
import {INVEST_STATUS,} from '@/service/intelligence/mapping/enum.js';
export default {
  name: "InvestComponent",
  components:{formSection,},
  props: {
    curRecord: {
      type: Object,
      default: () => { return {} },
    },
  },
  data() {
    return {
      resultInfo:{
        // isReport:false,
        remark:"",
      },
      radioList:[
        {name: INVEST_STATUS.INVEST_01_CN, value:INVEST_STATUS.INVEST_01, disabled:false,},
        {name: INVEST_STATUS.INVEST_02_CN, value:INVEST_STATUS.INVEST_02, disabled:false,},
        {name: INVEST_STATUS.INVEST_03_CN, value:INVEST_STATUS.INVEST_03, disabled:false,},
      ],
      rules:{
        result: [{
          required: true,
          message: '请选择处置方式',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['change', 'blur',],
        },],
      },
    };
  },
  created() {
    this.resultInfo.result = this.curRecord.result;
    this.resultInfo.remark = this.curRecord.remark || "";
  },
  mounted() {
    this.$refs.resultForm.setRules(this.rules);
  },
  methods: {
    // 确认
    handlerConfirm() {
      this.$refs.resultForm.validate(vaild => {
        if(vaild){
          this.$modal.showLoading('正在反馈...');
          inteligenceService.investResult({
            uuid: this.curRecord.uuid,
            ...this.resultInfo,
          }).then(res => {
            this.$modal.hideLoading();
            if(res.success) {
              this.$u.toast('反馈处置方式成功');
              res.bean.result = this.resultInfo.result;
              this.$emit("confirm", res.bean);
            } else{
              this.$u.toast(res.msg);
            }
          }).catch(e => {
            console.log(e);
            this.$modal.hideLoading();
          });
        }
      });
    },
    change(e){
      console.log(e);
    },
  },
};
</script>
<style lang="scss" scoped>
.single-page {
  padding: 10px;
  .nav-right-icon {
    color: #FFF;
    margin-right: 15px;
  }

}
</style>
